package blaha.genalg.graphgen;

import blaha.genalg.beans.Board;
import blaha.genalg.methods.ReadAllProperties;

/**
 * Check, if point has any connection with other point. If not, is marked
 * 
 * @author peta
 * 
 */
public class RemoveDisconnectedPoints {

	/**
	 * Purge board from solitude points(nodes)
	 * 
	 * @param board
	 * @param settings
	 * @param showIsolatedStructures
	 *            indicate, if this should be really true
	 * @return
	 */
	public Board Purge(Board board, ReadAllProperties settings) {

//		if (!settings.showIsolatedStructures) {
//			// removes only points without connection
//			for (int i = 0; i < Board.matrixOfJoins.length; i++) {
//				boolean wasSet = false;
//				for (int j = 0; j < Board.matrixOfJoins[0].length; j++) {
//					// if point has connection on point, those shall be marked
//					// as connected on right side
//					if (Board.matrixOfJoins[i][j].isConnected()) {
//						Board.map.get(j).solitude = false;
//						wasSet = true;
//					}
//				}
//				// those who were at connection on left side shall be marked
//				// also
//				if (wasSet)
//					Board.map.get(i).solitude = false;
//
//			}
//		} else {
//			for (int i = 0; i < Board.matrixOfJoins.length; i++) {
//				for (int j = 0; j < Board.matrixOfJoins[0].length; j++) {
//					Board.map.get(j).solitude = false;
//					Board.map.get(i).solitude = false;
//				}
//			}
//
//		}
		
		for (int i = 0; i < Board.matrixOfJoins.length; i++) {
			for (int j = 0; j < Board.matrixOfJoins[0].length; j++) {
				Board.map.get(j).solitude = false;
				Board.map.get(i).solitude = false;
			}
		}

		// finds graphs with no connection witch others graphs
		// hledej mezery ve sloupcich a uloz je do pole
		// ArrayList<MatrixOfGraph> mog = new ArrayList<MatrixOfGraph>();
		// int o=0,p=0;
		// while((o==ReadAllProperties.getxBoard())&&(p==ReadAllProperties.getyBoard())){
		// MatrixOfGraph m = new MatrixOfGraph();
		// if(board.getColumnConnectionCount(p)==0){
		// m.setBeginX(p);
		// }
		// else p++;
		//			
		// if(board.getLineConnectionCount(o)==0){
		//				
		// }
		// else o++;
		// }

		// hledej mezery v radcich a urci velikost rozdelenych matic.

		// najdi nejvetsi a s ostatnimi spoj/smaz
		return board;
	}

}
